package com.design.命令模式;

import java.util.ArrayList;
import java.util.List;

public class Consumer {

	public static void main(String[] args) {
		/**
		 * 
		 * 客户端
		 * 
		 */
		
		Fruit fruit = new Fruit();
		Milk milk = new Milk();
		Mouse mouse = new Mouse();
		
		System.out.println("--------");
		
		Menu menu = new Menu();
		menu.writeMenu(new OrderFruit(fruit));
		menu.writeMenu(new OrderMilk(milk));
		menu.writeMenu(new OrderMouse(mouse));
		
		menu.execute();
		
		System.out.println("-------------------");
		
		Menu cMenu = new Menu();
		cMenu.writeMenu(new CancelFruit(fruit));
		cMenu.writeMenu(new CancelMilk(milk));
		cMenu.writeMenu(new CancelMouse(mouse));
		
		cMenu.execute();
		
		System.out.println("=========");
		
		List<Command> commands = new ArrayList<Command>();
		commands.add(new OrderFruit(fruit));
		commands.add(new CancelFruit(fruit));
		
		commands.add(new OrderMilk(milk));
		commands.add(new OrderMouse(mouse));
		
		Menu mm = new Menu();
		mm.writeMenus(commands);
		mm.execute();
		
	}
	
}
